package com.tedu.ds.advertisement.controller;

import com.tedu.ds.advertisement.pojo.dto.AdvertisementParam;
import com.tedu.ds.advertisement.pojo.dto.AdvertisementQuery;
import com.tedu.ds.advertisement.service.AdvertisementService;
import com.tedu.ds.base.response.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/v1/advertisement")
@Api(tags = "广告模块")
public class AdvertisementController {
    @Autowired
    private AdvertisementService advertisementService;

    @PostMapping("/select")
    @ApiOperation("查询功能")
    public JsonResult select(@RequestBody AdvertisementQuery advertisementQuery) {
        return JsonResult.ok(advertisementService.select(advertisementQuery));
    }

    @PostMapping("/save")
    @ApiOperation("新增和更新功能")
    public JsonResult save(@RequestBody AdvertisementParam advertisementParam) {
        advertisementService.save(advertisementParam);
        return JsonResult.ok();
    }

    @PostMapping("/update/status/{id}/{status}")
    @ApiOperation("修改广告状态")
    public JsonResult updateStatus(
            @PathVariable Integer id, @PathVariable String status) {
        advertisementService.updateStatus(id,status);
        return JsonResult.ok();
    }

    @PostMapping("/delete/{id}")
    @ApiOperation("删除功能")
    public JsonResult delete(@PathVariable Integer id) {
        advertisementService.delete(id);
        return JsonResult.ok();
    }
}
